package leetcode.code1424;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;

public class Solution2 {
	//
	public int[] findDiagonalOrder(List<List<Integer>> nums) {
		int size = 0;
		for (int i = 0; i < nums.size(); i++) {
			size += nums.get(i).size();
		}
		int[] ans = new int[size];
		PriorityQueue<int[]> queue = new PriorityQueue<>((a, b) -> a[0] - b[0]);
		int index = 0;
		queue.add(new int[] { index++, 0, 0 });
		while (!queue.isEmpty()) {
			int[] cur = queue.poll();
			ans[cur[0]] = nums.get(cur[1]).get(cur[2]);
			if (cur[2] == 0 && cur[1] + 1 < nums.size()) {
				queue.add(new int[] { index++, cur[1] + 1, 0 });
			}
			if (nums.get(cur[1]).size() > cur[2] + 1) {
				queue.add(new int[] { index++, cur[1], cur[2] + 1 });
			}
		}
		return ans;
	}

	public enum Hello {
		/**
		 * 春天
		 */
		spring, /**
		 * 冬天
		 */
		winter;
	}

	static String[] dics = new String[] { "春天", "冬天" };

	static Map<String, Hello> map = new HashMap<>();

	static {
		map.put("春天", Hello.spring);
		map.put("冬天", Hello.winter);
	}

	public enum Hello2 {
		spring("春天"), winter("冬天");
		private String name;
		Hello2(String name) {
			this.name = name;
		}
	}
	public static void main(String[] args) {
		System.out.println(Hello.spring.ordinal());
		System.out.println(Hello.winter.ordinal());
		System.out.println(dics[Hello.spring.ordinal()]);
		System.out.println(dics[Hello.winter.ordinal()]);
		System.out.println(map.containsKey("春天"));
		System.out.println(map.containsKey("夏天"));
		System.out.println(map.get("春天"));
		System.out.println(Hello2.spring.name);
		System.out.println(Hello2.spring);
	}

}
